package com.example.demo.server.common;


public class CommonResponse {
    // 1. 状态码
    private int code;
    // 2. 状态码描述信息
    private String msg;
    // 3. 返回数据
    private Object data;

    public static CommonResponse success(Object data) {
        CommonResponse result = new CommonResponse();
        result.setCode(200);
        result.setData(data);
        return result;
    }
    public static CommonResponse success(Object data, String msg) {
        CommonResponse result = new CommonResponse();
        result.setCode(200);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static CommonResponse fail(int code, String msg) {
        CommonResponse result = new CommonResponse();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static CommonResponse fail(int code, String msg, Object data) {
        CommonResponse result = new CommonResponse();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
